<html>
<head><meta charset="utf-8"><title>Combined LintPass? · clippy · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/index.html">clippy</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Combined.20LintPass.3F.html">Combined LintPass?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="228808907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Combined%20LintPass%3F/near/228808907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Combined.20LintPass.3F.html#228808907">(Mar 04 2021 at 16:54)</a>:</h4>
<p>rustc has a <code>BuiltinCombinedLateLintPass</code> with all their builtin lints. It's a maze of macros to define this struct but the result is static dispatch for all the lint pass callbacks. I can only imagine that this has quite a significant performance impact (all the empty callbacks are optimized out for one thing). Clippy could re-use the macros to define <code>ClippyLateLintPass</code> with very little added boilerplate. I have a local proof-of-concept. Is this something we want to pursue?</p>



<a name="228830538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Combined%20LintPass%3F/near/228830538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Michael Wright <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Combined.20LintPass.3F.html#228830538">(Mar 04 2021 at 19:01)</a>:</h4>
<p>Have you done any actual measurements? What are you using as a benchmark?</p>



<a name="228840962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Combined%20LintPass%3F/near/228840962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Combined.20LintPass.3F.html#228840962">(Mar 04 2021 at 20:05)</a>:</h4>
<p>My imagination. <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> Valid point, it should be benchmarked. Honestly I'm not sure how to benchmark it and I would love to receive some pointers. But I'm just asking if we're willing to consider the change in the first place from a complexity standpoint.</p>



<a name="228843510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Combined%20LintPass%3F/near/228843510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Combined.20LintPass.3F.html#228843510">(Mar 04 2021 at 20:21)</a>:</h4>
<p>Can we share those macros with rustc?</p>
<p>If it brings performance improvements, I'm open to it, as long as those macros are really good documented. (After looking at the macros in rustc for  5 minutes, I still don't understand what's going on)</p>



<a name="228855279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Combined%20LintPass%3F/near/228855279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Combined.20LintPass.3F.html#228855279">(Mar 04 2021 at 21:40)</a>:</h4>
<p>rustc is sharing their macros with us!</p>



<a name="228855658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Combined%20LintPass%3F/near/228855658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Combined.20LintPass.3F.html#228855658">(Mar 04 2021 at 21:43)</a>:</h4>
<p>Here's my proof of concept. It mostly works! :) <a href="https://github.com/camsteffen/rust-clippy/commit/9c5e54064b026677aabe5782f6d9a6eeee01d840">https://github.com/camsteffen/rust-clippy/commit/9c5e54064b026677aabe5782f6d9a6eeee01d840</a></p>



<a name="228856596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Combined%20LintPass%3F/near/228856596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Combined.20LintPass.3F.html#228856596">(Mar 04 2021 at 21:49)</a>:</h4>
<p>That looks pretty clean to me. I don't understand how the macros work, but it looks clean. What is with the lints, that you didn't remove from the register function?</p>



<a name="228857574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Combined%20LintPass%3F/near/228857574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Combined.20LintPass.3F.html#228857574">(Mar 04 2021 at 21:56)</a>:</h4>
<p>Another question: Can we still auto-generate this?</p>



<a name="228858532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Combined%20LintPass%3F/near/228858532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Combined.20LintPass.3F.html#228858532">(Mar 04 2021 at 22:02)</a>:</h4>
<p>I need to find a way to make it work with constructors with parameters such as config.</p>



<a name="228858600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Combined%20LintPass%3F/near/228858600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Combined.20LintPass.3F.html#228858600">(Mar 04 2021 at 22:02)</a>:</h4>
<p>I assume maintaining <code>cargo dev update_lints</code> is a requirement</p>



<a name="228858842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Combined%20LintPass%3F/near/228858842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Combined.20LintPass.3F.html#228858842">(Mar 04 2021 at 22:04)</a>:</h4>
<p>It helps me to think about these macros as inverted functions. Think of <code>a!(b, c)</code> as <code>b!(a!(), c)</code>.</p>



<a name="228858878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Combined%20LintPass%3F/near/228858878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Combined.20LintPass.3F.html#228858878">(Mar 04 2021 at 22:04)</a>:</h4>
<p>Keeping the ability to generate this code is a _must have_ requirement for Clippy.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>